package com.relytosoft.mizar.analyze.common.utils;

import cn.hutool.core.util.StrUtil;

import java.time.LocalDateTime;

/**
 * @author wss
 * @version 1.0
 * @date 2022/5/23 14:06
 */
public class DateUtil {
    private static final String DEFAULT_TIME_PATTERN = "HHmmss";

    /**
     * 获取当前时间的 时分秒字符串格式
     *
     * @param timePattern
     * @return
     */
    public static final String toTimeStr(String timePattern) {
        if (StrUtil.isBlank(timePattern)) {
            timePattern = DEFAULT_TIME_PATTERN;
        }
        return cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), timePattern);
    }

    /**
     * 获取当前天星期第几天
     * MONDAY --->1   SUNDAY --->7
     *
     * @return
     */
    public static final int thisDayOfWeek() {
        int dayOfWeek = cn.hutool.core.date.DateUtil.thisDayOfWeek();
        int i = dayOfWeek - 1;
        if (i == 0) {
            return 7;
        }
        return i;
    }

}
